<?php
/**
 * Created by PhpStorm.
 * User: ZhangWei
 * Date: 2018/4/14
 * Time: 12:53
 */

namespace App\Logic;


use App\Jobs\SendTempMessage;
use App\Models\UserBuyOrder;

class MessageLogic
{
    public static function sendUserBuyTempMessage(UserBuyOrder $user_buy_order)
    {
        //给作者发消息
        $temp_data = [
            'touser' => $user_buy_order->user->wx_user->open_id,
            'template_id' => 'F5mv_kGCAJYeHQZPlT14TmZ43qWAS2p3EKeXTG3z-wg',
            'page' => '/pages/index/main',
            'form_id' => $user_buy_order->prepay_id,
            'data' => [
                'keyword1' => $user_buy_order->order_sn,
                'keyword2' => (string)$user_buy_order->created_at,
                'keyword3' => $user_buy_order->item->title,
                'keyword4' => $user_buy_order->pay_money,
                'keyword5' => $user_buy_order->user->name,
            ],
        ];
        SendTempMessage::dispatch($temp_data);
    }

}